package com.mxpio.erp.common.plan.entity;

import com.mxpio.erp.common.jpa.model.Notice;
import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import com.mxpio.erp.common.workshop.entity.OutsourceOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Author : 吴盼盼
 * @Datetime : 2022/11/14 11:32
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PLAN_OD_DEFECT_NOTICE")
@Schema(description="组织需求不良品退料处理通知单")
public class ODDefectiveRejNotice extends Notice {
	private static final long serialVersionUID = 1L;


	@Transient
    private List<ODDefectiveRejNoticeLine> defectiveRejNoticeLines;

    @Transient
    private OutsourceOrder order;
    @Override
    public List<? extends NoticeLine> getNoticeLines() {
        return this.defectiveRejNoticeLines;
    }

    @Override
    public String initTypeCode() {
        return "DP1";
    }

    @Override
    public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
        ODDefectiveRejNoticeLine noticeLine = new ODDefectiveRejNoticeLine();
        noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
        noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
        noticeLine.setItemCode(orderExcuteVo.getItemCode());
        noticeLine.setNoticeNo(this.getNoticeNo());
        noticeLine.setQuantity(orderExcuteVo.getQuantity());
        noticeLine.setSort(orderExcuteVo.getSort());
        noticeLine.setLotNo(orderExcuteVo.getLotNo());
        noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
        noticeLine.setReporter(orderExcuteVo.getReporter());
        noticeLine.setReportProc(orderExcuteVo.getReportProc());
        noticeLine.setExceptionType(orderExcuteVo.getExceptionType());
        noticeLine.setDefectiveReason(orderExcuteVo.getDefectiveReason());
        noticeLine.setDefectiveDesc(orderExcuteVo.getDefectiveDesc());
        noticeLine.setResponseUnit(orderExcuteVo.getResponseUnit());
        noticeLine.setSupplementFlag(orderExcuteVo.getSupplementFlag());
        noticeLine.setBomWhCode(orderExcuteVo.getBomWhCode());//订单bom行对应仓库code
        return noticeLine;
    }


}
